﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Genom_Project
{
    public partial class open_db : Form
    {
        public open_db()
        {
            InitializeComponent();
            last_work();
        }

        private void confirm_Click(object sender, EventArgs e)
        {
            if (net_bd.Text != "" && local_bd.Text != "") MessageBox.Show("Выберете один источник данных!");
            else
            {
                if (net_bd.Text != "") main_window.last_net_bd = net_bd.Text; 
                if (local_bd.Text != "")  main_window.last_local_bd = local_bd.Text;
                this.Close();
            }
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void B_local_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Файл Excel|*.XLSX;*.XLS| Файл XML|*.XML";
            if (open.ShowDialog() == DialogResult.OK)
            {
                local_bd.Text = open.FileName;
            }
        }

        private void last_work()
        {
            if (main_window.last_net_bd != "") net_bd.Text = main_window.last_net_bd;
            if (main_window.last_local_bd != "") local_bd.Text = main_window.last_local_bd;
        }
    }
}
